//
//  GetTimeNow.m
//  Daybook
//
//  Created by dllo on 16/5/20.
//  Copyright © 2016年 zhangbin. All rights reserved.
//

#import "GetTimeNow.h"

@implementation GetTimeNow

+ (NSString *)getTimeNow {
    //获得系统时间
    NSDate *senddate=[NSDate date];
    NSDateFormatter  *dateformatter=[[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"HH:mm"];
    NSString *locationString = [dateformatter stringFromDate:senddate];
    return locationString;
}

+ (NSString *)getDateNow {
    //获得系统日期
    NSDate *senddate=[NSDate date];
    NSCalendar  *cal = [NSCalendar  currentCalendar];
    NSUInteger  unitFlags = NSCalendarUnitDay| NSCalendarUnitMonth |NSCalendarUnitYear;
    NSDateComponents * conponent= [cal components:unitFlags fromDate:senddate];
    NSInteger year =[conponent year]; 
    NSInteger month=[conponent month];
    NSInteger day=[conponent day];
    NSString *  nsDateString= [NSString  stringWithFormat:@"%04ld-%02ld-%02ld", year, month, day];
    return nsDateString;
}

@end
